<?php

/*
 * 客户选购内容
 */

/**
 * Description of choosecontent_model
 *
 * @author Jack.Y
 */
class ChooseContent_model extends CI_Model {

    //重载CI_Model
    public function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->model('Base_Model');
    }

    /*
     * Insert_ChooseContent
     * 写入数据库
     */

    function Insert_ChooseContent($array = FALSE, $se_id = FALSE) {
        foreach ($array as $array_item) {
            $se_item = split(",", $array_item);
            $cc_id = $this->Base_Model->GetID('cc_id', 'db_chooseContent'); //获取标准ID
            $data = array(
                'cc_id' => $cc_id,
                'cu_id' => $se_id, //客户编号
                'pt_id' => $se_item[0], //商品编号
                'pt_name' => $se_item[1], //商品名称
                'pt_num' => $se_item[2], //商品数量
                'cc_state' => OBJ_STATE_VALID
            );
            $this->db->insert('db_chooseContent', $data);
        }
    }

    /*
     * DelDate
     * 删除数据
     */

    function DelDate($id = FALSE) {
        $this->db->delete('db_chooseContent', array('cu_id' => $id));
    }
    
        /*
     * GetForState
     * 获取列表数据
     * 参数：状态;套系标示
     */

    function GetListForState($cu_id = FALSE) {
        $query = $this->db->get_where('db_chooseContent', array('cu_id' => $cu_id));
        //返回结果
        return $query->result_array();
    }

}

?>
